home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / Kubuntu 8.10 / kubuntu-8.10-desktop-i386.iso / casper / filesystem.squashfs / usr / lib / pm-utils / sleep.d / 90clock < prev    next >
Text File  |  2008-10-15  |  821b  |  42 lines

  1. #!/bin/sh
  2. # Synchronize system time with hardware time.
  3. # TODO: Split NTP handling to its own hook. Having it here is ugly and silly.
  4. #       Do modern kernels handle this correctly?  If so, we should detect that
  5. #       and skip this hook.
  6.  
  7. . "${PM_FUNCTIONS}"
  8.  
  9. NTPD_LOCK="pm-ntpd.lock"
  10.  
  11. suspend_clock()
  12. {
  13.     if try_lock "${NTPD_LOCK}"; then
  14.         trap 'release_lock "${NTPD_LOCK}"' 0
  15.         stopservice ntpd
  16.     fi
  17.     /sbin/hwclock --systohc >/dev/null 2>&1 0<&1
  18. }
  19.  
  20. resume_clock()
  21. {
  22.     /sbin/hwclock --hctosys >/dev/null 2>&1 0<&1
  23.     rc=$?
  24.     # Bring back ntpd _after_ NetworkManager and such come back...
  25.     (     spin_lock "${NTPD_LOCK}";
  26.         trap 'release_lock "${NTPD_LOCK}"' 0
  27.         sleep 20; 
  28.         restartservice ntpd; ) &
  29.     return $rc
  30. }
  31.  
  32. case "$1" in
  33.     hibernate|suspend)
  34.         suspend_clock
  35.         ;;
  36.     thaw|resume)
  37.         resume_clock
  38.         ;;
  39.     *) exit $NA
  40.         ;;
  41. esac
  42.